var PATH_PREFIX ="";

function setPathPrefix(path){
	PATH_PREFIX =  path;
}
$(function() {
	// 给select2组件加载样式
	WASP_WIDGET.initializeSelectStyle();
	WASP_WIDGET.triggerDateStyleWithYMD("#clearDate");
	// 注册清空事件
    WASP_WIDGET.registerResetClearEvent();
    $("#excpReordContent").hide();
});

var clearBeginTime = $("#clearBeginTime");
var clearEndTime = $("#clearEndTime");
var exceptionFlag = $("#exceptionFlag");
var docGetTime2 = $("#docGetTime2");
var startTime2 = $("#startTime2");
var endTime2 = $("#endTime2");
var docExportTime2 = $("#docExportTime2");
var changeDayTime2 = $("#changeDayTime2");
var excInfo = $("#excInfo");


function queryByCondtion(flag) {
	var clearDate = $.trim($("#clearDate").val());
	if(clearDate == null || clearDate == ''){
		ctools.alert("请选择查询日期", "", "warning");
		return;
	}
	$.ajax({
		async:true,
		url:PATH_PREFIX + 'queryClearException.do',
		type:"post",
		dataType:'json',
		data:{
			"sp[clearDate]" : clearDate
		},
		success:function(data){
			if(!!data && !!data.clearVo){
				completeClearTime(data.clearVo);
				completeDealTime(data.clearVo);
			}else{
				clearBeginTime.html("");
				clearEndTime.html("");
				exceptionFlag.html("");
				docGetTime2.html("");
				startTime2.html("");
				endTime2.html("");
				docExportTime2.html("");
				changeDayTime2.html("");
			}
			if(!!data.exceptionList && data.exceptionList.length >0){
				completeException(data.exceptionList);
			}else{
				var textStr = "<tr>"+
								"<td class='white-bg'></td>" + 
								"<td class='white-bg'></td>" +
								"<td class='white-bg'></td>" + 
								"<td class='white-bg'></td>" +
								"<td class='white-bg'></td>" +
							  "</tr>" +
							  "<tr>" +
								"<td class='white-bg'></td>" + 
								"<td class='white-bg'></td>" +
								"<td class='white-bg'></td>" + 
								"<td class='white-bg'></td>" +
								"<td class='white-bg'></td>" +
							  "</tr>";
				excInfo.html(textStr);
			}
		}
	});		
}

function showTypeContent(id,tId){
	$(".typeContent").hide();
	$("#"+id).show();
};

function completeClearTime(obj){
	clearBeginTime.html(obj.clearStartTime);
	clearEndTime.html(obj.clearEndTime);
	exceptionFlag.html(obj.exceptionFlag);
}

function completeDealTime(obj){
	docGetTime2.html(obj.docGetTime);
	startTime2.html(obj.clearStartTime);
	endTime2.html(obj.clearEndTime);
	docExportTime2.html(obj.docExportTime);
	changeDayTime2.html(obj.changeDayTime);
}


function completeException(obj){
	var textStr = "";
	for(var i = 0;i<obj.length;i++){
		textStr +="<tr>";
		textStr +="<td>" + obj[i].exceptionType +  "</td>";
		textStr +="<td>" + obj[i].exceptionName +  "</td>";
		textStr +="<td>" + obj[i].exceptionDesc +  "</td>";
		textStr +="<td>" + obj[i].exceptionStartTime +  "</td>";
		textStr +="<td>" + obj[i].exceptionEndTime +  "</td>";
		textStr +="</tr>";
	}
	excInfo.html(textStr);
}

/*
 * 

var $dealTimeList = $("#dealTimeList");

$(function() {
	$dealTimeList.jqGrid({   
		url:PATH_PREFIX + 'queryDealTime.do', 
		datatype: "json",
		colNames:["数据处理项目", "数据处理完成时间"],        
		colModel:[  { name: 'dealProject', index: 'dealProject' ,width:30},       
		            { name: 'dataCompTime', index: 'dataCompTime', width: 30, resizable: true, sortable: false }
				  ],
		rowNum: 20,
        rowList: [20, 30, 50],
        rownumbers: true,
        rownumWidth: 50,
        postData: {'sp[clearDate]' : ""},
        prmNames: { search: "search", page: "pageNo", rows: "limit" },
        height: 'auto',
        width: false,
        autowidth:false,
        editurl: '',
        viewrecords: true,
        cellEdit: false,
        shrinkToFit: true,
        grouping: false,
        jsonReader: {
            root: "items", //结果集
            records: "total", //总记录数 
            total: "pageCount", //总页数
            page: "pageNo", //当前页 
            repeatitems: false // (4) 
        },  
		multiselect:false,
		viewrecords: true,
		hidegrid: false, 
		gridComplete: function(){
			var ids = $dealTimeList.jqGrid('getDataIDs');
			for(var i = 0;i < ids.length;i++){
				var rowId = ids[i];
				$dealTimeList.jqGrid('setRowData', ids[i]);
			}	
		}
	});
	$dealTimeList.jqGrid('setFrozenColumns');
	$dealTimeList.navGrid('#dealTimeListPage',{edit:false,add:false,del:false,search:false,refreshstate:'current'});
	jqGridResize($dealTimeList);
});

var $excpReordist = $("#excpReordist");

$(function() {
	$excpReordist.jqGrid({   
		url:PATH_PREFIX + 'queryExceptionInfo.do', 
		datatype: "json",
		colNames:["异常类型", "异常名称","异常内容","异常处理开始时间","异常处理结束时间"],        
		colModel:[  { name: 'exceptionType', index: 'exceptionType' , width: 30},       
					{ name: 'exceptionName', index: 'exceptionName', width: 30, resizable: true, sortable: false },
					{ name: 'exceptionDesc', index: 'exceptionDesc', width: 30, resizable: true, sortable: false },
					{ name: 'exceptionStartTime', index: 'exceptionStartTime', width: 30, resizable: true, sortable: false },
		            { name: 'exceptionEndTime', index: 'exceptionEndTime', width: 30, resizable: true, sortable: false }
				  ],
		rowNum: 20,
        rowList: [20, 30, 50],
        rownumbers: true,
        rownumWidth: 50,
        postData: {'sp[clearDate]' : ""},
        prmNames: { search: "search", page: "pageNo", rows: "limit" },
        height: 'auto',
        width: false,
        autowidth:true,
        editurl: '',
        viewrecords: true,
        cellEdit: false,
        shrinkToFit: true,
        grouping: false,
        jsonReader: {
            root: "items", //结果集
            records: "total", //总记录数 
            total: "pageCount", //总页数
            page: "pageNo", //当前页 
            repeatitems: false // (4) 
        },  
		multiselect:false,
		viewrecords: true,
		hidegrid: false, 
		gridComplete: function(){
			var ids = $excpReordist.jqGrid('getDataIDs');
			for(var i = 0;i < ids.length;i++){
				var rowId = ids[i];
				$excpReordist.jqGrid('setRowData', ids[i]);
			}	
		}
	});
	$excpReordist.jqGrid('setFrozenColumns');
	jqGridResize($excpReordist);
});
*/
